package com.xt.wikiperfumapi.Controller.other;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xt.wikiperfumapi.model.BrandInfo;
import com.xt.wikiperfumapi.model.IngredientInfo;
import com.xt.wikiperfumapi.model.OrderInfo;
import com.xt.wikiperfumapi.model.PerfumeInfo;
import com.xt.wikiperfumapi.model.vo.RestBean;
import com.xt.wikiperfumapi.service.impl.BrandInfoServiceImpl;
import com.xt.wikiperfumapi.service.impl.IngredientInfoServiceImpl;
import com.xt.wikiperfumapi.service.impl.OrderInfoServiceImpl;
import com.xt.wikiperfumapi.service.impl.PerfumeInfoServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RequestMapping("/api/other")
@RestController
public class OtherController {

    @Resource
    PerfumeInfoServiceImpl perfumeInfoService;

    @Resource
    BrandInfoServiceImpl brandInfoService;

    @Resource
    IngredientInfoServiceImpl ingredientInfoService;
    @Autowired
    private OrderInfoServiceImpl orderInfoServiceImpl;

    @RequestMapping("list")
    public RestBean dataList() {
        long perfumeInfoCount = perfumeInfoService.count(new QueryWrapper<PerfumeInfo>().eq("is_deleted", 0));
        long brandInfoCount = brandInfoService.count(new QueryWrapper<BrandInfo>().eq("is_deleted", 0));
        long ingredientInfoCount = ingredientInfoService.count(new QueryWrapper<IngredientInfo>().eq("is_deleted", 0));
        List list=new ArrayList();
        list.add(perfumeInfoCount);
        list.add(brandInfoCount);
        list.add(ingredientInfoCount);
        return RestBean.success(list);
    }

    @RequestMapping("dataN")
    public RestBean datan(){
        long perfumeInfoCount = perfumeInfoService.count(new QueryWrapper<PerfumeInfo>().eq("is_deleted", 0));
        long brandInfoCount = brandInfoService.count(new QueryWrapper<BrandInfo>().eq("is_deleted", 0));
        long ingredientInfoCount = ingredientInfoService.count(new QueryWrapper<IngredientInfo>().eq("is_deleted", 0));
        long orderCount = orderInfoServiceImpl.count(new QueryWrapper<OrderInfo>().eq("is_deleted", 0));
        List list=new ArrayList();
        list.add(perfumeInfoCount);
        list.add(brandInfoCount);
        list.add(ingredientInfoCount);
        list.add(orderCount);
        return RestBean.success(list);
    }

}
